function missingNumber(nums: number[]): number {
    if(nums[0]!=0){
        return 0;
    }

    let l = 0;
    let r = nums.length - 1;
    let center = Math.floor((l + r) / 2);
    while (l < r) {
        if (nums[center] == center) {
            l = center + 1;
            center = Math.floor((l + r) / 2);
            continue;
        }
        if (nums[center] != center) {
            r = center - 1;
            center = Math.floor((l + r) / 2);
            continue;
        }
    }
    console.log(l,r,center);
    if (nums[center] == center) {
        return center + 1;
    } else {
        return center;
    }

};
console.log(missingNumber([0,2]));